package com.hbnu.commonclass;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class ObjectDemo1 {
    public static void main(String[] args) {
        Animal dog = new Animal("狗",5);
        System.out.println(dog.toString());
        //还有一个判断是否是同一对象的，使用重写后的equals


        String str = "Quisque habet mortem";
        System.out.println("字符串长度：" + str.length());
        System.out.println(str.indexOf('a'));
        System.out.println(str.indexOf("mor"));
        System.out.println(str.substring(4,7));
        System.out.println(str.trim());


        Calendar calendar = Calendar.getInstance();
        System.out.println(calendar.getWeekYear());
        System.out.println(calendar.MONTH);

        Date date = calendar.getTime();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E");      //格式化时间
        System.out.println(simpleDateFormat.format(date));
        System.out.println(date.getTime());                                             //时间戳



    }
}
